// $Id: SqlServerSettingsEditor.cs 66 2008-05-07 19:57:30Z nvivo $

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DBLGen.UI;

namespace DBLGen.Plugins.Import
{
    public partial class SqlServerSettingsEditor : PluginSettingsEditor
    {
        public SqlServerSettingsEditor()
        {
            InitializeComponent();
        }

        private void AuthenticationModeChanged(object sender, EventArgs e)
        {
            panelUserPass.Enabled = !rbUseWindowsAuth.Checked;
        }

        private void SqlServerSettingsEditor_LoadingSettings(object sender, EventArgs e)
        {
            SqlServerSettings settings = (SqlServerSettings) Settings;

            txtServer.Text = settings.Host;
            txtUser.Text = settings.User;
            txtPass.Text = settings.Password;
            txtDatabase.Text = settings.Database;

            rbUseWindowsAuth.Checked = settings.UseWindowsAuthentication;
            rbUseSqlAuth.Checked = !rbUseWindowsAuth.Checked;
        }

        private void SqlServerSettingsEditor_SavingSettings(object sender, EventArgs e)
        {
            SqlServerSettings settings = (SqlServerSettings) Settings;

            settings.Host = txtServer.Text;
            settings.User = txtUser.Text;
            settings.Password = txtPass.Text;
            settings.Database = txtDatabase.Text;
            settings.UseWindowsAuthentication = rbUseWindowsAuth.Checked;
        }
    }
}
